

#import <Cocoa/Cocoa.h>
#import <AudioUnit/AudioUnit.h>

#import "UDMOctogris_XYView.h"
#import "CommonSettings.h"

@interface UDMOctogris_UI : NSView
{
	IBOutlet UDMOctogris_XYView* mXYView;
	
	IBOutlet NSBox* mSourcesDistance;
	IBOutlet NSButton*	mLinkSourcesDistances;
	IBOutlet NSScrollView* mDistanceScroller;
	
	IBOutlet NSBox* mSpeakersAttenuation;
	IBOutlet NSScrollView* mAttenuationScroller;

	
	IBOutlet NSButton*	mShowGridLines;
	IBOutlet NSButton*	mEnableJoystick;
	IBOutlet NSButton*	mLinkMovement;
	
	IBOutlet NSTextField *mMovementLabel;
	IBOutlet NSPopUpButton *mMovementPopUp;
	
	IBOutlet NSPopUpButton *mShowLevelsPopUp;
	IBOutlet NSButton *mTakeAttenuation;
	
	NSMutableArray* mSourcesDistanceLabels;
	NSMutableArray* mSourcesDistanceSliders;
	
	NSMutableArray* mSpeakersAttenuationSliders;
	NSMutableArray* mSpeakersAttenuationCheckboxes;
	NSMutableArray* mSpeakersLevels;
	
	IBOutlet NSSlider*	mLevelAttack;
	IBOutlet NSSlider*	mLevelRelease;
	IBOutlet NSSlider*	mParamSmooth;
	IBOutlet NSTextField*	mLevelAttackValue;
	IBOutlet NSTextField*	mLevelReleaseValue;
	IBOutlet NSTextField*	mParamSmoothValue;
	
	AudioUnit 				mAU;
    AUParameterListenerRef	mParameterListener;
	int						mNumberOfSources;
	int						mNumberOfSpeakers;
	
	NSTimer *mTimer;
	
	int64 mLastShownProcessCounter;
	float mLevelAdjustment;
	
	float					mAttenBoxHeight;
	float					mDistBoxHeight;
	
	BOOL					mOldLinkSourceValue;
	BOOL					mOldLinkMoveValue;
	
	BOOL					mDisableModeSelector;
}

BOOL	mSetSliderToDefault;

- (IBAction) showLevelsChanged:(id)sender;
- (IBAction) takeAttenuationChanged:(id)sender;

- (IBAction) levelAttackChanged:(id)sender;
- (IBAction) levelReleaseChanged:(id)sender;
- (IBAction) paramSmoothChanged:(id)sender;

- (IBAction) linkSourcesChanged:(id)sender;
- (IBAction) showGridLinesChanged:(id)sender;
- (IBAction) movementModeChanged:(id)sender;
- (IBAction) enableJoystickChanged:(id)sender;
- (IBAction) linkMovementChanged:(id)sender;



- (void)setAU:(AudioUnit)inAU;

- (void)_synchronizeUIWithParameterValues;
- (void)_addListeners;
- (void)_removeListeners;
- (void)_parameterListener:(void *)inObject parameter:(const AudioUnitParameter *)inParameter value:(Float32)inValue;

- (void) scrollToTop;

- (void) populateUI;

- (void) linkSourcesChanged2:(BOOL)linkValue;
- (void) linkMovementChanged2:(BOOL)linkValue;

- (IBAction) sourceDistanceChanged:(id)sender;
- (IBAction) speakerMuteChanged:(id)sender;
- (IBAction) speakerAttenuationChanged:(id)sender;



- (void) sliderNotify:(id)sender type:(int)t event:(AudioUnitEventType)e;
- (void) notifyEventType:(AudioUnitEventType)type forParameterID:(AudioUnitParameterID)parameterID;

@end
